Added support for calling TryValidateModel#54
Draft
icnocop wants to merge 4 commits intoSharpGrip:masterfrom
Draft
Added support for calling TryValidateModel#54icnocop wants to merge 4 commits intoSharpGrip:masterfrom
icnocop wants to merge 4 commits intoSharpGrip:masterfrom
Conversation
5654e44 to
945cab4
Compare
…erted into AggregateException
736f137 to
1daba17
Compare
mvdgun
reviewed
Sep 10, 2025
| // If built in model validation is disabled return true for later validation in the action filter. | ||
| return disableBuiltInModelValidation || base.Validate(metadata, key, model, alwaysValidateAtTopLevel); | ||
| bool isBaseValid = disableBuiltInModelValidation || base.Validate(metadata, key, model, alwaysValidateAtTopLevel); | ||
| return ValidateAsync(isBaseValid, key, model).GetAwaiter().GetResult(); |
Member
There was a problem hiding this comment.
@icnocop not sure about this one, won't this result in deadlocks?
| private readonly bool disableBuiltInModelValidation; | ||
|
|
||
| public FluentValidationAutoValidationObjectModelValidator(IModelMetadataProvider modelMetadataProvider, IList<IModelValidatorProvider> validatorProviders, bool disableBuiltInModelValidation) | ||
| public FluentValidationAutoValidationObjectModelValidator( |
| IModelMetadataProvider metadataProvider, | ||
| ValidationStateDictionary? validationState) | ||
| { | ||
| return new FluentValidationAutoValidationValidationVisitor(actionContext, validatorProvider, validatorCache, metadataProvider, validationState, disableBuiltInModelValidation); |
| { | ||
| public static class FluentValidationHelper | ||
| { | ||
| public static async Task<ValidationResult?> ValidateWithFluentValidationAsync( |
Member
There was a problem hiding this comment.
@icnocop this method feels kinda hacky by taking a IServiceProvider as an argument, what do you think?
There was a problem hiding this comment.
What else do you recommend?
IServiceProvider is needed to dynamically get the validator based on the type of the model.
Member
|
@icnocop gave this one some more thought and I am afraid I am not going to include it as long as the current MVC validation pipeline is still not async. Let's revisit this issue when dotnet/aspnetcore#31905 lands. It is currently one of the top upvoted issue in the aspnet core repo so hopefully it makes the .NET 11 release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #53